import request from '@/utils/request'

/**
 * 开放城市编辑
*/

export const OpenCitySave= (data:OpenCity): Promise<ServiceResponse<any>> => !data.isEdit  ? request({ url: 'opencity', data ,method:'POST'}) : request({ url: `opencity/${data.regionId}`, data ,method:'PUT'})

/**
 * 开放城市删除
 * @param id 
 * @returns 
 */
export const OpenCityDelete = (regionId: number): Promise<ServiceResponse<any>> => request({ url: `opencity/${regionId}`,method:'DELETE'})

/**
 * 开放城市详情
 * @param id 
 * @returns 
 */
export const GetOpenCityDetails =(regionId:number):Promise<ServiceResponse<OpenCity>>=>request({url:`opencity/${regionId}`})

 /**
 * 开放城市修改排序
 * @param id 
 * @returns 
 */
 export const UpdateOpenCitySequence = (regionId: number,sequence: number): Promise<ServiceResponse<any>> => request({ url: 'opencity/sequence', data:{regionId , sequence} ,method:'GET'})


/**
 * 商业圈删除
 * @param id 
 * @returns 
 */
export const businessDelete = (id: number): Promise<ServiceResponse<any>> => request({ url: `opencity/business/${id}`,method:'DELETE'})
/**
 * 是否热门
*/
export const UpdateOpenCityHot = (regionId: number,hot: boolean): Promise<ServiceResponse<any>> => request({ url: `opencity/hot/${regionId}`, data:{ hot } ,method:'GET'})

/**
 * 城市商业圈
 * @param id 
 * @returns 
 */
export const GetListByRegionId = (regionId: number): Promise<ServiceResponse<BusinessCircle[]>> => request({ url: `opencity/business/list`,data:{ regionId },method:'GET'})